' This BASIC Anywhere Machine program by Charlie Veniot
' is a port and mod of Dav's QB64pe program
' found at https://qb64phoenix.com/forum/showthread.php?tid=1838&pid=17786#pid17786
' - small changes by zxdunny: more 3D look of sin-based gradients instead of linear gradients
' - small change by Charlie: got rid of one CIRCLE statement
'  📚Why two CIRCLE statements instead of one?  Likely because of rounding errors in the CIRCLE routine, size and position of "virtual pixels" sometimes leaves gaps between an inner circle and an outer circle.  The virtual pixels are calculated based on the number of horizontal and vertical pixels of the SCREEN mode, the aspect ratio of the pixels (i.e. height being some factor of width), and all pixels getting adjusted as the browser window gets resized.)
' - small change by Charlie: added scrolling and reduced resolution for performance

dh = 200
screen _newimage(600,dh,24)
declare SUB ball (x, y, size, r, g, b)


DO
    ball (int(RND * dh)+75, int(RND * dh), int(RND * 75), int(RND * 255), int(RND * 255), int(RND * 255))
    _delay 0.05
LOOP
 
SUB ball (x, y, size, r, g, b)
    _DISPLAY

    FOR s = 0 TO size
    	v=sin((1-s/size)*1.57)
    	c=_RGB32(int(r*v),int(g*v),int(b*v))
        CIRCLE (x, y), s, c
        CIRCLE (x+1, y), s, c
    NEXT
    scroll +1,0
    _DISPLAY
 
END SUB